package bootstrap

import (
	"base"
	"config/table"
	"leaf/log"
)

type Config struct {
	LogLevel       string
	LogPath        string
	LogFlat        int
	GameConfigPath string
}

func (config *Config) Parse() (err error) {
	if config == nil {
		return
	}

	if level := config.LogLevel; level != "" {
		if base.Logger, err = log.New(config.LogLevel, config.LogPath, config.LogFlat); err != nil {
			return
		}
		log.Export(base.Logger)
	}

	if path := config.GameConfigPath; path != "" {
		if err = config_table.Init(path); err != nil {
			return err
		}
	}

	return
}
